<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
</head>
<body>


    <header class="aui-bar aui-bar-nav" id="aui-header" style="background: linear-gradient(to right,#f370af 0,#5515ee  100%);">
        <a class="aui-btn aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left" style="color:#FFF"></span>
        </a>
        <div id="title" class="aui-title">播放中</div>
		
		
		        <a class="aui-btn aui-pull-right" tapmode onclick="toShezhi()">
            <span class="aui-iconfont aui-icon-gear" style="color:#FFF"></span>
        </a>

    </header> 
	



</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">

	var api_url = localStorage.getItem('api_url');
	
    var baores_uid = localStorage.getItem('baores_uid');
    var baores_token = localStorage.getItem('baores_token');
	
/////  初始化执行   S /////
/////  apiready  一打开就执行的 函数
  apiready = function(){
  

	
record_play_history();


    //////////////////////    获取解析API接口解析值  //////////////////////
 

			api.ajax({
				url: 'http://play.baores.com/api/', 
				method: 'get',              
				data: {
                  values: {
					uid: baores_uid,   
					token: baores_token,   
					wap: 1,   
					url: api.pageParam.video   
                  }
              }
			}, function(ret, err) {
				if(ret) {
	//		alert( JSON.stringify( ret.url ) );  
						if(ret.code = 200){
						
						//	var jiexiurl = ret.url;
							
						//	openVideoWin(jiexiurl,'test');
							    api.openFrame({
								name: 'video_jiexi_api_play_frm',
								url: 'video_jiexi_api_play_frm.html',
								bounces: false,    //禁止下拉
								rect: {
									x: 0,  
									y: headerPos.h,
									w: 'auto',
									h: 'auto'
								},

								pageParam:{video:ret.url,title:api.pageParam.title}
							})

							
						
						}else{
						
						
						alert( '错误' );
						
						}
						
					
					api.hideProgress();

				} else {
					api.hideProgress();
					//alert( JSON.stringify( err ) );
				}
			});

    //////////////////////    获取解析API接口解析值  //////////////////////


		

			
  api.setKeepScreenOn({
    keepOn: true
});


  api.parseTapmode();
  var header = $api.byId('aui-header');
  $api.fixStatusBar(header);  
  var headerPos = $api.offset(header);
  var body_h = $api.offset($api.dom('body')).h;
   
   
	if(api.pageParam.title === undefined){
	
	
			title.innerHTML = '<img src="" style="width: 20px;display: inline;margin-right: 10px;"> 影视特权';
	
	}else{
	
			title.innerHTML = '<img src="" style="width: 20px;display: inline;margin-right: 10px;">'+api.pageParam.title;
   
	}

		


  }

/////  初始化执行   E /////






	function record_play_history(){
//	 alert(api.pageParam.title);
	  api.ajax({
	      url: api_url+'/login/login/playjilu', 
           method: 'post',                  
	      data:{
	      	values:{
	      		uid: localStorage.getItem('user_id'),
	      		title: api.pageParam.title,
	      		url: api.pageParam.video,
	     // 		time: new Date().format('yyyy-MM-dd hh:mm:ss'),
	      		ping: getPing(api.pageParam.video)
	      	}
	      }
      },function(ret,err){
      });
	}

	function getPing(url){
		if(url.indexOf("youku.com")>0){
			return '优酷';
		}else if(url.indexOf("iqiyi.com")>0){
			return '爱奇艺';
		}else if(url.indexOf("v.qq.com")>0){
			return "腾讯"
    }else if(url.indexOf("tv.sohu.com")>0){
			return "搜狐"
    }else if(url.indexOf("fun.tv")>0){
      return "风行"
    }else if(url.indexOf("pptv.com")>0){
      return "pptv"
    }else if(url.indexOf("mgtv.com")>0){
      return "芒果"
    }else if(url.indexOf("1905.com")>0){
      return "M1905"
    }else if(url.indexOf("baofeng.com")>0){
      return "暴风"
    }else if(url.indexOf("le.com")>0){
      return "乐视"
    }else if(url.indexOf("xxooweizhiurl.com")>0){
      return "未知"
		}

	}




      function toShezhi(){


        api.openWin({
            name: 'shezhi_win',
            url: 'shezhi_win.html', 
        });
		
		
		
	//打开页面时 关闭当前页
		api.addEventListener({
         name:'viewdisappear'
     },function(){
         api.closeWin({
              name:api.winName
         });
     });

    }







//////////////////////   返回按钮  方法   closeWin    S //////////////////////
  function closeWin(){
    api.setScreenOrientation({
        orientation: 'portrait_up'
    });
      api.closeWin({
      });
  }
//////////////////////   返回按钮  方法   closeWin    E //////////////////////


</script>
</html>
